package com.cyanite.playlv2api.parsers.json;

import com.cyanite.playlv2api.types.TaskCategory;
import org.json.JSONException;
import org.json.JSONObject;

public class TaskCategoryParser extends AbstractParser<TaskCategory> {

    @Override
    public TaskCategory parse(JSONObject json) throws JSONException {

        TaskCategory obj = new TaskCategory();
        if (json.has("xid")) {
            obj.setId(String.valueOf(json.getInt("xid")));
        }
        if (json.has("scount")) {
            obj.setTasksUndone(json.getInt("scount"));
        }
        if (json.has("type")) {
            obj.setType(json.getInt("type"));
        }
        return obj;
    }
}